package com.hst.web.sys.proxy;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.hst.core.Page;
import com.hst.core.ServiceContext;
import com.hst.core.dao.IORDao;
import com.hst.core.dao.ISQLDao;
import com.hst.core.meta.proxies.DefaultDataProxy;
import com.hst.core.meta.proxies.OREntityUtils;
import com.hst.web.auth.po.User;
import com.hst.web.base.service.UserRoleService;
import com.hst.web.sys.entity.TRole;

public class EmployeeUpgradeProxy extends DefaultDataProxy{
	
	@Autowired
	OREntityUtils orUtil;
	
	@Autowired
	IORDao dao;
	
	@Autowired
	ISQLDao sql;
	
	@Autowired
	UserRoleService us;
	
	@SuppressWarnings("unchecked")
	@Override
	public Page<?> list(Map<String, ?> query, int pageIdx) {
		User user = (User) ServiceContext.getInstance().getUser();
		Map<String,Object> map = (Map<String, Object>) query;
		TRole role = us.userRole(user.getId());
		if("2".equals(role.getRoleLevel())) {
			map.put("companyCode", user.getCompanyCode());
		}
		Page<?> page = sql.list("employee.list-employee-upgrade", map, pageIdx, 20);
		return page;
	}
}
